import express from 'express';
import { authenticate } from '../middleware/auth';
import * as circleController from '../controllers/circleController';
import * as circlePostController from '../controllers/circlePostController';
import * as circleCommentController from '../controllers/circleCommentController';

const router = express.Router();

// 圈子相关路由
router.post('/', authenticate, circleController.createCircle);
router.get('/', circleController.getCircles);
router.get('/:id', circleController.getCircleDetail);
router.put('/:id', authenticate, circleController.updateCircle);
router.delete('/:id', authenticate, circleController.deleteCircle);

// 圈子成员相关路由
router.post('/:id/join', authenticate, circleController.joinCircle);
router.post('/:id/leave', authenticate, circleController.leaveCircle);
router.get('/:id/members', circleController.getCircleMembers);

// 圈子帖子相关路由
router.post('/:circleId/posts', authenticate, circlePostController.createPost);
router.get('/:circleId/posts', circlePostController.getPosts);
router.get('/posts/:id', circlePostController.getPostById);
router.put('/posts/:id', authenticate, circlePostController.updatePost);
router.delete('/posts/:id', authenticate, circlePostController.deletePost);

// 帖子点赞相关路由
router.post('/posts/:id/like', authenticate, circlePostController.likePost);
router.post('/posts/:id/unlike', authenticate, circlePostController.unlikePost);

// 帖子置顶和加精相关路由
router.put('/posts/:id/top', authenticate, circlePostController.toggleTop);
router.put('/posts/:id/essence', authenticate, circlePostController.toggleEssence);

// 帖子评论相关路由
router.post('/posts/:postId/comments', authenticate, circleCommentController.createComment);
router.get('/posts/:postId/comments', circleCommentController.getComments);
router.put('/comments/:id', authenticate, circleCommentController.updateComment);
router.delete('/comments/:id', authenticate, circleCommentController.deleteComment);

// 评论点赞相关路由
router.post('/comments/:id/like', authenticate, circleCommentController.likeComment);
router.post('/comments/:id/unlike', authenticate, circleCommentController.unlikeComment);

export default router; 